
export function getNum(m: number, n: number): number {
	// 枚举法
	// 获取最小数字

	// 最大公约数
	const min = Math.min(m, n)

	for (let i = min; i > 0; i--) {
		if (m % i === 0 && n % i === 0) {
			return i
		}
	}

	return -1
};

function getNum1(m: number, n: number): number {
	// 递归

	const resultList: number[] = [];
	// 最大公倍数
	function fn(m: number, n: number) {
		const max = Math.max(m, n);
		const min = Math.min(m, n);
		if (max % min === 0) {
			resultList.push(max);
			return
		} else {
			let i = 1;
			while (++i) {
				if (m % i === 0 && n % i === 0) {
					resultList.push(i);
					m = m / i
					n = n / i
					fn(m, n)
					return
				}

				if (i > max) {
					resultList.push(m)
					resultList.push(n)
					return
				}
			}
		}
	}

	fn(m, n)
	return resultList.reduce((p, n) => p * n)
};


const result = getNum1(30, 20);

console.log(result);



